
import { useImmer } from 'use-immer';
export default  function ImmerComponent() {
    const [info, setInfo] = useImmer({
      username: {
        first: 'xiao',
        last: 'ming',
      },
      age: 20,
    });
    function updateInfo() {
      setInfo(draft => {
        draft.username.first = 'da';
        // draft.address = 'beijing';
      });
    }
    return (
      <div>
      <button onClick={updateInfo}>改名字</button>
      <div>{JSON.stringify(info)}</div>
    </div>
    );
  }